<?php
class Model
{

	static function getAllProduct()
	{
		$link   =   mysql_connect( );
    	$DatabaseName = "indoorsybuy";
    	$dataBase = mysql_select_db( $DatabaseName,   $link) or die( "Could   not   connect:   "   .   mysql_error()); 
		$query = "SELECT  * FROM `catalogOfProduct`  WHERE 1 ORDER by id";
		$result   =   mysql_query( $query,$link) ;
		while ($r = mysql_fetch_assoc($result))
		{
			$lines[$r['id']] = $r;
		}

		return $lines;
	}
	
	static function getProductByType($typeOfProduct)
	{
		$link   =   mysql_connect( );
    	$DatabaseName = "indoorsybuy";
    	$dataBase = mysql_select_db( $DatabaseName,   $link) or die( "Could   not   connect:   "   .   mysql_error()); 
		$query = "SELECT  * FROM `catalogOfProduct`  WHERE type='$typeOfProduct' ORDER by id";
		$result   =   mysql_query( $query,$link) ;
		while ($r = mysql_fetch_assoc($result))
		{
			$lines[$r['id']] = $r;
		}

		return $lines;
	}
	
	static function getAllType()
	{
		$link   =   mysql_connect( );
    	$DatabaseName = "indoorsybuy";
    	$dataBase = mysql_select_db( $DatabaseName,   $link) or die( "Could   not   connect:   "   .   mysql_error()); 
		$query = "SELECT  * FROM `typeOfProduct`  WHERE 1 ORDER by id";
		$result   =   mysql_query( $query,$link) ;
		while ($r = mysql_fetch_assoc($result))
		{
			$lines[$r['id']] = $r;
		}

		return $lines;
	}
	
	static function getPoductById($id)
	{
		$link   =   mysql_connect( );
    	$DatabaseName = "indoorsybuy";
    	$dataBase = mysql_select_db( $DatabaseName,   $link) or die( "Could   not   connect:   "   .   mysql_error()); 
		$query = "SELECT  * FROM `catalogOfProduct`  WHERE id='$id' ORDER by id";
		$result   =   mysql_query( $query,$link) ;
		$r = mysql_fetch_assoc($result);
		

		return $r;
	}

}
?>
